#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>

using namespace std;

namespace ouyang
{
	class string
	{
	public:

		string(const char* str = "")
		{
			_size = strlen(str);
			_capacity = _size;
			_str = new char[_capacity + 1];

			strcpy(_str, str);
		}

		string(const string& s)
		{
			_str = new char[s._capacity + 1];
			strcpy(_str, s._str);
			_size = s._size;
			_capacity = s._capacity;
		}

		string& operator=(string s)
		{
			swap(s);

			return *this;
		}

		~string()
		{
			delete[] _str;
			_str = nullptr;
			_size = _capacity;
		}

		void swap(string& s)
		{
			std::swap(_str, s._str);
			std::swap(_size, s._size);
			std::swap(_capacity, s._capacity);
		}

		const char* c_str() const
		{
			return _str;
		}

	private:

		char* _str;
		size_t _size;
		size_t _capacity;
	};

}

int main()
{
	ouyang::string s("Hello World");
	ouyang::string s1(s);
	ouyang::string s2;
	s2 = s1;

	cout << s.c_str() << endl;
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	return 0;
}